/**
 * 
 */
package com.yidu.view;

import java.io.IOException;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yidu.bean.TbComment;
import com.yidu.commom.Tool;
import com.yidu.message.Message;
import com.yidu.service.TbCommentService;

/**
 *
 * @author yichengming
 * 2018年7月24日下午10:14:07
 * @version 1.0
 */
@Controller
@RequestMapping("/comment")
public class TbCommentAction {
	@Resource
	private TbCommentService commentService;
	//输出打印控制台
		Logger logger  = Logger.getLogger(TbImageAction.class);
		
		//json
		ObjectMapper mapper = new ObjectMapper();
		
		//消息信息类
		Message msg = new Message();
		
		@RequestMapping("/insertComment")
		@ResponseBody
		public Message insertComment(TbComment comment) {
			/*
			//得到文件
			 MultipartHttpServletRequest mreq = (MultipartHttpServletRequest)request; 
			 
		     MultipartFile file = mreq.getFile("image");
		     
		     logger.info(file.getOriginalFilename());
		     String fileName=null;
		     if(!file.equals(null)){
		    	//使用工具类方法将图片写入相应路径
			 		fileName = Tool.output(file, request);
			 		logger.info(fileName);
		     }*/
			
			comment.setComId(UUID.randomUUID().toString());
			System.err.println("进入增加action！！！！！！！！！！！！");
			int rows=commentService.insertSelective(comment);
			if(rows>0){
				msg.setMsg("1");
				return msg;
			}else{
				msg.setMsg("0");
				return msg;
			}
		}
}
